package com.zjj.wangluo.lianxi.tcp06;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author zhoujunjie
 * @desc TODO
 * @date
 *
 */
public class ThreadPool {

    private ThreadPoolExecutor pool;

    public ThreadPool(int maxPoolSize , int queueSize){
        pool = new ThreadPoolExecutor(1 , maxPoolSize ,
                60 , TimeUnit.SECONDS , new LinkedBlockingQueue<>(queueSize));
    }

    //执行方法
    public void execute(Runnable runnable){
        pool.submit(runnable);
    }
}